{% extends "data_list.html" %}

{% load i18n %}


{% block extend_disabled_actions %}
    {% if request.user|HasPerm:"iclock.browse_device" %}
       {%get_config_option "DEVICE_DISABLE_ACTIONS"%}
    {% else %}
        $("#id_search").remove();
        alert(gettext("对不起,您没有访问该页面的权限,不能浏览更多信息！"));
        window.location.href="/{{ request.surl }}accounts/login/";
    {% endif %}<!--iclock.browse_device-->
    
{% endblock %}

{% block extrajs %}	
    {% if request.user|HasPerm:"iclock.browse_device" %}
        $("#id_datalist").find("#id_OpBrowseLog").remove();
        $("#id_datalist").find("#OpChangeElevatorParamters").remove();
        {% if "mysite.iaccess&mysite.att"|hasApp or "mysite.iaccess"|hasApp %}
            $("#id_OpSearchACPanel").parent().append($("#id_OpSearchACPanel"));
        {% else %}
            {% if "ONLY_POS"|filter_config_option %}
                            $("#id_OpSearchACPanel").remove();
            {% else %}
                {% if "mysite.att"|hasApp %}
                                $("#id_OpSearchACPanel").remove();
                            {% endif %}
            {% endif %}
        {% endif %}
        $("#id_OpSearchACPanel").after($("#id_op_for_tab").find(".div_leftBottomLine").eq(0));
    {% else %}
        $("#id_search").remove();
        alert(gettext("对不起,您没有访问该页面的权限,不能浏览更多信息！"));
        window.location.href="/{{ request.surl }}accounts/login/";
    {% endif %}<!--iclock.browse_device-->

{% endblock %}

{% block extend_model_grid %}
    {% if request.user|HasPerm:"iclock.browse_device" %}
        'model_actions':true,
        'object_actions':true,
        'multiple_select':true,
        'need_plus_sign':false,
    {% else %}
        $("#id_search").remove();
        alert(gettext("对不起，您没有访问该页面的权限，不能浏览更多信息！"));
        window.location.href="/{{ request.surl }}accounts/login/";
    {% endif %}<!--iclock.browse_device-->
{% endblock %}
{% block addjs %}
    {% if "USE_ABROAD_ATT"|filter_config_option %}
        $(".portlet").removeClass("floatL").css({width:"77%",float:"right"});
        $("#id_main_div").before("<div id='AreaAdjust' class ='div_box clearL' style='float:left;width:20%;height:465px;_width:20%;margin:5px 0px 0px 10px !important;*margin:5px 0px 0px 5px !important;' >"
        +"<h1>"
			+"{% trans '区域' %}"
		+"</h1>"
		+"<a id='id_queryall' class ='link_style' href='javascript:void(0)' title='"+"{% trans '显示全部设备' %}"+"'style ='position:absolute; top:6px;right:5px' >"
			+"{% trans '显示全部设备' %}"
		+"</a>"
		+"<div id ='id_area_select' style='width:100%;' >"
		+"</div> "
	    +"</div>");
        var after_init=function(){
            $('#id_area_select').parent(".div_box").hide();
            $("#id_main_div").css({width:"100%",float:"right"});
            return true;
        }
        var after_close=function(){
            //$(".rightBox").eq(1).attr("class","rightBox1");
            $('#id_area_select').parent(".div_box").show();
            $("#id_main_div").css({width:"77%",float:"right"});
            return true;
        }
        var after_submit=function(){
            //$(".rightBox").eq(1).attr("class","rightBox1");
            $('#id_area_select').parent(".div_box").show();
            $("#id_main_div").css({width:"77%",float:"right"});
            return true;
        }
        $.ajax({
          	type: "POST",
          	url:"/data/personnel/Area/choice_data_widget?areatree=True",
          	dataType:"html",
          	success:function(json){
                $("#id_area_select").hide().html(json).show();
            }
        });
        $("#id_queryall").click(function(){
               $("#id_AreaSelect").find("p[class*='s']").attr("class","t")
               $("#id_area_select").find("input[type='hidden']").attr("value","")
               $('#id_datalist').get(0).g.init_query=[]
               $('#id_datalist').get(0).g.base_query=["device_type__exact=1"]
               $('#id_datalist').get(0).g.load_data()
        })
        function before_query(strwhere){
            strwhere.push("device_type__exact=1");
            return strwhere;
        }
        function reflash_child_area_list(event, treeId, treeNode){
            var parent_id = treeNode.id;
            var strwhere=[];
            strwhere = before_query(strwhere)
            strwhere.push("area__id__exact="+parent_id);
            var $grid = $('#id_datalist');
            var datalist=$grid.get(0);
            datalist.g.init_query=strwhere;
            datalist.g.load_data();
         }
    {% endif %}
{% endblock %}


